package com.halen.user.service;

import com.halen.user.dao.StudentMapper;
import com.halen.user.entity.Student;
import com.halen.user.entity.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("studentServiceImpl")
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Autowired
    private TeacherService teacherService;

    @Transactional
    @Override
    public int createStudent(Student student) {
        studentMapper.insertSelective(student);
        Teacher teacher = new Teacher();
        teacher.setTid(2);
        teacher.setUsername("老张");
        teacher.setPassword("laowang");
        teacherService.createTeacher(teacher);
        return 0;
    }
}
